<?php

namespace App\Components;

use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;

/**
 * @method static static info($message, array $context = [])
 * @method static static warning($message, array $context = [])
 * @method static static error($message, array $context = [])
 * @method static static debug($message, array $context = [])
 * @method static static notice($message, array $context = [])
 * @method static static log($level, $message, array $context = [])
 */
class Log
{
    /**
     * @param $name
     * @param $arguments
     */
    public static function __callStatic($name, $arguments)
    {
        self::getInstance()->$name(...$arguments);
    }

    /**
     * @return LoggerInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    private static function getInstance()
    {
        return ApplicationContext::getContainer()->get(LoggerFactory::class)->get(config('app_env'));
    }
}